package com.mm.cloud.lease.service.impl.convert.room;

import com.mm.cloud.lease.dto.room.form.SaveRoomDTO;
import com.mm.cloud.lease.dto.room.form.UpdateRoomDTO;
import com.mm.cloud.lease.entity.Room;
import com.mm.cloud.lease.vo.room.RoomVO;

public class RoomConvert {

    /**
     * 单个保存房间信息
     *
     * @param dto
     * @return
     */
    public static Room convert(SaveRoomDTO dto) {
        Room room = new Room();
        room.setHousingId(dto.getHousingId());
        room.setDoorNumber(dto.getDoorNumber());
        room.setFloor(dto.getFloor());
        room.setOrientation(dto.getOrientation());
        room.setInsideSpace(dto.getInsideSpace());
        room.setBedroom(dto.getBedroom());
        room.setLivingroom(dto.getLivingroom());
        room.setBathroom(dto.getBathroom());
        room.setKitchen(dto.getKitchen());
        room.setRoomSort(dto.getRoomSort());
        return room;
    }

    public static Room convert(UpdateRoomDTO dto) {
        Room room = convert((SaveRoomDTO) dto);
        room.setId(dto.getId());
        return room;
    }

    /**
     * 房间实体转VO
     *
     * @param room
     * @return
     */
    public static RoomVO convertToVO(Room room) {
        if (room == null) {
            return null;
        }
        RoomVO roomVO = new RoomVO();
        roomVO.setId(room.getId());
        roomVO.setCompanyId(room.getCompanyId());
        roomVO.setHousingId(room.getHousingId());
        roomVO.setDoorNumber(room.getDoorNumber());
        roomVO.setFloor(room.getFloor());
        roomVO.setOrientation(room.getOrientation());
        roomVO.setInsideSpace(room.getInsideSpace());
        roomVO.setBedroom(room.getBedroom());
        roomVO.setLivingroom(room.getLivingroom());
        roomVO.setBathroom(room.getBathroom());
        roomVO.setKitchen(room.getKitchen());
        roomVO.setIsLease(room.getIsLease());
        roomVO.setIsEarnest(room.getIsEarnest());
        roomVO.setRoomSort(room.getRoomSort());
        roomVO.setCreaterId(room.getCreaterId());
        roomVO.setUpdaterId(room.getUpdaterId());
        roomVO.setCreateTime(room.getCreateTime());
        roomVO.setUpdateTime(room.getUpdateTime());
        roomVO.setIsDelete(room.getIsDelete());
        return roomVO;
    }

}
